package com.xh.bussiness.exam.controller;

import com.xh.bussiness.exam.bean.request.PaperPublishQueryRequest;
import com.xh.bussiness.exam.bean.request.PaperPublishSaveRequest;
import com.xh.bussiness.exam.service.IPaperPublishService;
import com.xh.core.bean.AjaxResult;
import com.xh.core.bean.XhPage;
import com.xh.core.constant.AjaxResultConstant;
import com.xh.core.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
 * @Author daiwei
 * @Description
 * @Date 2019/4/9 11:45
 **/
@Api(tags="测评-测评试卷发布相关接口")
@RestController
@RequestMapping("/exam/paperPublish")
public class PaperPublishController extends BaseController {

    @Autowired
    private IPaperPublishService paperPublishService;

    @PostMapping("/addPublish")
    @ApiOperation("发布测评试卷")
    public AjaxResult addPublish(PaperPublishSaveRequest bean){
        String msg=paperPublishService.addPaperPublish(bean);
        return new AjaxResult(msg==null,msg);
    }

    @PostMapping("/modifyStatus")
    @ApiOperation("测评试卷发布状态修改")
    public AjaxResult modifyStatus(PaperPublishSaveRequest bean){
        String msg=paperPublishService.modifyPaperPublishStatus(bean);
        return new AjaxResult(msg==null,msg);
    }

    @PostMapping("/queryPaperPublishPage")
    @ApiOperation("测评试卷发布分页查询")
    public AjaxResult queryPaperPublishPage(XhPage page,PaperPublishQueryRequest bean){
        return new AjaxResult(AjaxResultConstant.Result.SUCCESS,"",paperPublishService.queryPaperPublish(page,bean));
    }

    @PostMapping("/getPaperPublish")
    @ApiOperation("测评试卷发布信息查询")
    public AjaxResult getPaperPublish(String id){
        return new AjaxResult(AjaxResultConstant.Result.SUCCESS,"",paperPublishService.getPaperPublishById(id));
    }

    @PostMapping("/deletePaperPublish")
    @ApiOperation("删除")
    public AjaxResult deletePaperPublish(String id){
        paperPublishService.delete(id);
        return new AjaxResult(AjaxResultConstant.Result.SUCCESS);
    }
}
